<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/7/31
  Time: 19:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/common/head.jsp"%>
<%@include file="/common/global.jsp"%>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="viewport" content="height=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <title></title>
    <link rel="stylesheet" href="${ctxPath}/static/css/common2.css"/>
    <link rel="stylesheet" href="${ctxPath}/static/css/register.css"/>
</head>
<body>
<script>
    function validate(o){
        var $this = o.length > 0 ? o: $(o);
        logger.info(o);
        console.log($this);
        console.log($this.val());
        if (!$this.val()) {
            var tip = '请输入'+$this.attr('message');
            layer.msg(tip,{time:1000});
            return '['+tip+']';
        }
        var name = $this.attr('name');
        if ('phoneNo' == name) {
            if(!(/^1[34578]\d{9}$/.test($this.val()))){
                var tip = '输入的手机号有误';
                layer.msg(tip,{time:2000,anim:4,btn:['确定','取消']});
                return tip;
            }
        }
    }
</script>
<div class="register">
    <div class="regTop">
        <span>验证查询</span>
        <%--<a class="back" href="${ctxPath}/sysUser/do_member_Page">&lt;&nbsp;返回</a>--%>
    </div>
    <div class="content">
        <%--<div class="point">
            <span>注册成功后，手机号也可为登录账号。</span>
        </div>--%>
        <form id="theForm" action="javascript:void(0)" method="POST">
            <div class="message">
                <input type="tel" placeholder="输入手机号" pattern="[0-9]{11}" name="phoneNo" required/>
                <input type="text" placeholder="输入验证码" pattern="[0-9]{6}" name="smsCode" onkeyup="this.value=this.value.replace(/\D/g,'')"/>
                <div class="icons">
                </div>
                <button id="smsCodeBtn" class=" btn btn-primary code" >获取验证码</button>
            </div>
            <button id="submit" class="submit">去查询</button>
        </form>
    </div>
</div>
</body>
</html>
<%@include file="/common/footer.jsp"%>
<%@include file="/common/tooltip.jsp"%>
<script>
   $(function(){
       $('#smsCodeBtn').click(function(){
           logger.info({data:'你点了获取短信验证码!', groupName:'----短信验证码分割线----'});
           if(validate($('#theForm input[name="phoneNo"]'))){ return; };
           $.ajax({
               url:'${ctxPath}/common/smsCode',
               type:'GET',
               data:{'phoneNo': $('#theForm input[name="phoneNo"]').val()},
               dataType:'json',
               success:function(data){
                   logger.info({data:data, groupName:'-----感情不是你想买就能买----'});
                   if (data) {
                       if ( data.status == '200') {
                           layer.msg('验证码已发送至您的手机!请注意查收!',{time:5000,anim:4,btn:['确认','取消']});
                       } else if ( data.status == '400' ){
                           layer.msg('短信发送失败!请稍后再试!',{time:5000,anim:4,btn:['确认','取消']});
                       } else if ( data.status == '406' ) {
                           layer.msg('手机号不能为空!',{time:5000,anim:4,btn:['确认','取消']});
                       }
                   }
               },
               error:function(errorMessage){
                   console.group('----这里是异常!----');
                   logger.info(errorMessage);
                   console.groupEnd();
               }
           });
       });

       $("#submit").click(function(){
           var phoneNo = $("#theForm input[name='phoneNo']").val();
           var smsCode = $("#theForm input[name='smsCode']").val();
           if (!phoneNo) {
               layer.msg("请输入手机号!", {time:2000,btn:['确认','取消']});
               return;
           }
           if (!smsCode) {
               layer.msg("请输入手机验证码!", {time:2000,btn:['确认','取消']});
               return;
           }
           $("#theForm").attr('action','${ctxPath}/busiOrder/dataGrid').submit();
       });
   });
</script>


